--当受
local dangshou = fk.CreateSkill {
    name = "mcdh_dangshou"
}

dangshou:addEffect(fk.EventPhaseStart,{
    can_trigger = function(self, event, target, player, data)
        if target ~= player then
            if event == fk.EventPhaseStart then
                return player:hasSkill(self) and target.phase == Player.Draw and player:usedSkillTimes(self.name, Player.HistoryRound) == 0 and #player:getCardIds("h") > 0
            end
        end
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local card = room:askForCard(
                player,
                1, 1,
                false,
                self.name,
                true,
                ".",
                "#mcdh_dangshou_give:" .. target.id
        )
        if #card > 0 then
            self.cost_data = card
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:addPlayerMark(target,"@mcdh_dangshou-phase")
        room:obtainCard(
                target,
                self.cost_data,
                true,
                fk.ReasonGive,
                player.id,
                self.name
        )
    end
})

dangshou:addEffect(fk.DrawNCards,{
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
        return player:getMark("@mcdh_dangshou-phase") ~= 0 and target == player
    end,
    on_cost=function (self, event, target, player, data)
        return true
    end,
    on_use = function(self, event, target, player, data)
        data.n = data.n -1
    end,
})

Fk:loadTranslationTable {
    ["mcdh_dangshou"] = "当受",
    [":mcdh_dangshou"] = "每轮限一次，其他角色摸牌阶段开始时，你可以交给其一张手牌并令其本阶段摸牌数-1。",
    ["@mcdh_dangshou-phase"] = "当受",
    ["#mcdh_dangshou_give"] ="当受:交给 %src 一张手牌并令其本阶段摸牌数-1。",
}

return dangshou